﻿using LibNiconico.NiconicoApi.PlayerStatus;
using LibNiconico.NiconicoApi.Utils;
using NicoView.Model.Service.Lives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace NicoView.Model.Service.Results
{
    public class NiconicoLiveConnectionResult : Result<NicoLiveService>, INiconicoConnectionResult
    {
        internal NiconicoLiveConnectionResult(NicoGetPlayerStatusResponse postKeyResult, NicoLiveService val, bool flag, string reason)
            : this(isNotLogin(postKeyResult), val, flag, reason)
        {

        }

        internal NiconicoLiveConnectionResult(bool notLogin, NicoLiveService val, bool flag, string reason)
            : base(val, flag, reason)
        {
            NotLogin = notLogin;

            this.Code = flag ? NiconicoConnectionResultCode.Succeed : NiconicoConnectionResultCode.Fail;
        }

        private static bool isNotLogin(NicoGetPlayerStatusResponse postKeyResult)
        {
            return postKeyResult.Error.Code == NicoErrorCode.NotLogin;
        }

        public bool NotLogin
        {
            get;
            private set;
        }




        public NiconicoConnectionResultCode Code
        {
            get;
            private set;
        }
    }

    public class NiconicoConnectionResult : INiconicoConnectionResult
    {
        internal NiconicoConnectionResult( NiconicoConnectionResultCode code, bool rslt, string failReason)
        {
            this.Code = code;
            this.Succeed = rslt;
            this.Message = failReason;
        }

        public bool NotLogin
        {
            get
            {
                return Code == NiconicoConnectionResultCode.NotLogin;
            }
        }

        public NiconicoConnectionResultCode Code
        {
            get;
            private set;
        }

        public bool Succeed
        {
            get;
            private set;
        }

        public string Message
        {
            get;
            private set;
        }
    }

}
